/**
 Copyright will be fixed soon.
 Author: Hiroshi Ota.
 $Date: $
 $Revision: $
*/

#include "PWConIO.h"

#ifdef _BRICKOS_
#include "conio.h"
#endif

PWConIO::PWConIO(void)
{
}

PWConIO::~PWConIO(void)
{
}

PWConIO* PWConIO::create()
{
        if (instance==0) {
                instance = new PWConIO();
        }
        return instance;
}

#ifndef _BRICKOS_
PWConIO::PWConIO(ISimulatorControl *sc)
: simCon(sc)
{
}

PWConIO* PWConIO::create(ISimulatorControl* sc)
{
	if (instance==0){
		instance = new PWConIO(sc);
	}
	return instance;
}

#endif

        // write bit-pattern for segments at position pos of LCD
void PWConIO::cputc_native(char mask, int pos)
{
#ifdef _BRICKOS_
        ::cputc_native(mask,pos);
#else
		if (simCon!=0){
			simCon->cputcLCD(ISimulatorControl::LCD_DISPLAY_MODE_NATIVE, mask, pos);
		}
#endif
}

        // write HEX digit to position pos of LCD
void PWConIO::cputc_hex(char c, int pos)
{
#ifdef _BRICKOS_
        ::cputc_hex(c,pos);
#else
		if (simCon!=0){
			simCon->cputcLCD(ISimulatorControl::LCD_DISPLAY_MODE_HEX, c, pos);
		}
#endif
}

        // write HEX word to LCD
void PWConIO::cputw(unsigned word)
{
#ifdef _BRICKOS_
        ::cputw(word);
#else
		if (simCon!=0){
			simCon->cputwLCD(word);
		}
#endif
}

        // write ASCII char to position pos of LCD
void PWConIO::cputc(char c, int pos)
{
#ifdef _BRICKOS_
        ::cputc(c,pos);
#else
		if (simCon!=0){
			simCon->cputcLCD(ISimulatorControl::LCD_DISPLAY_MODE_ASCII, c, pos);
		}
#endif
}

        // Write strings to LCD (Only first 5 chars)
void PWConIO::cputs(char* s)
{
#ifdef _BRICKOS_
        ::cputs(s);
#else
		if (simCon!=0){
			simCon->cputsLCD(s);
		}
#endif
}

        // clear user portion of LCD
void PWConIO::cls()
{
#ifdef _BRICKOS_
        ::cls();
#else
		if (simCon!=0){
			simCon->clearLCD();
		}
#endif
}


PWConIO* PWConIO::instance=0;
